layui.use(['layer','form','table','element','layedit','upload'],function () {
    var layer = layui.layer
        ,form = layui.form
        ,table =layui.table
        ,element = layui.element
        ,layedit = layui.layedit
        ,upload = layui.upload;


    $.ajax({
        url:"/admin/getDriverList"
        ,type:"POST"
        ,success:function (res) {
            var driverList = res.data.drivers;
            $("#user").empty();
            $("#user").append("<option value='0'>=====全部发送=====</option>");
            $.each(driverList,function (i,item) {
                $("#user").append("<option value='"+item.id+"'>"+item.userName+"</option>");
                form.render();
            });

            var ownerId = $("#ownerId").val();
            $("#owner").val(ownerId);
            form.render();
        }
        ,error:function () {
            layer.msg("系统错误！");
        }
    });


//提交表单
form.on('submit(form)',function (data) {

    var data = {
        "title":$("#title").val(),
        "content":$("#content").val(),
        "user":$("#user").val()
    };

    //保存项目
    $.ajax({
        url:"/admin/notice/save",
        type:"POST",
        data:data,
        success:function (result) {
            // console.log("data=="+form_data)
            if(result.flag){
                layer.msg(result.message);
                //清空内容
                // $("#form").reset();
                document.getElementById("form").reset();
                layui.form.render();
            }else{
                layer.msg(result.message);
            }
        },
        error:function () {
            layer.msg("系统错误！");
        }
    });

});

});